#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import rospy
import json
from flask import Blueprint,request, Response

from parser.cmdvel_parser import CmdvelParser
from tool.common import *

cmdvel_parser = CmdvelParser()
cmdvel_server = Blueprint("/cmdvel",__name__)


#---------------------------------#
#******#   flask-网络端口验证   #******#
#---------------------------------#
@cmdvel_server.before_request
def before():
    res_data = before_user(request)
    if res_data:
        return Response(json.dumps(res_data),  mimetype='application/json')




#---------------------------------#
    #******#   POST   #******#
#---------------------------------#
# 机器人方控设置
# req: 
# res: 
@cmdvel_server.route('/cmdvel_ctrl',methods=['POST'])
def Post_SetCmdvel():
    data = request.json
    res_data = cmdvel_parser.SetCmdvel(data)
    return Response(json.dumps(res_data),  mimetype='application/json')
